package homework.day08;

/**
 * 修改下面代码的编译
 * @author XingHaiYang
 * @date 2022/9/16 20:15
 */
public class Test02 {
	public static void main(String[] args) {
		Thread t1 = new Thread() {
			@Override
			public void run() {
				Foo.dosome();
			}
		};
		Thread t2 = new Thread() {
			@Override
			public void run() {
				Foo.dosome();
			}
		};
		t1.start();
		t2.start();
	}
}

class Foo{
	public static void dosome() {
		synchronized (Foo.class) {//静态方法，需要类对象作为锁对象，普通方法是this作为锁对象
			System.out.println("hello!");
		}
	}
}

